package com.tengju.bff.interfaces.manage.club.assembler;

import com.tengju.bff.interfaces.manage.club.vo.ClubVO;
import com.tengju.bff.interfaces.manage.club.vo.UserWithClubVO;
import com.tengju.bff.interfaces.shared.MobileVO;
import com.tengju.user.domain.model.club.Club;
import com.tengju.user.domain.model.user.StarLevelEnum;
import com.tengju.user.domain.model.user.UserInfo;

/**
 * @author chenhang
 * @Date 2021/1/13
 */
public class ClubAssembler {

    public static UserWithClubVO convertToUserWithClub(Club club, UserInfo userInfo) {
        UserWithClubVO userWithClubVO = new UserWithClubVO();
        if (userInfo != null) {
            userWithClubVO.setIdCode(userInfo.getIdCode().getValue());
            userWithClubVO.setNickName(userInfo.getNickName());
            userWithClubVO.setMobile(new MobileVO(userInfo.getWholePhoneNumber()));
            StarLevelEnum starLevel = StarLevelEnum.parseByCode(userInfo.getStarLevel());
            userWithClubVO.setStarLevel(starLevel.getCode());
            userWithClubVO.setStarLevelDesc(starLevel.getDesc());
        }
        if (club != null) {
            userWithClubVO.setClubId(club.getClubId().getValue());
            userWithClubVO.setClubName(club.getClubName());
        }
        return userWithClubVO;
    }

    public static ClubVO convertToClubListVo(Club club) {
        ClubVO clubVO = new ClubVO();
        clubVO.setClubId(club.getClubId().getValue());
        clubVO.setClubName(club.getClubName());
        return clubVO;
    }
}
